#!/bin/bash

# postinst script for system-data-console-fonts
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:sys $BASEDIR/boot
	chown root:sys $BASEDIR/boot/fonts
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/10x18.fnt ] && rm -f $BASEDIR/boot/fonts/10x18.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/10x18.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/10x18.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/10x18b.fnt ] && rm -f $BASEDIR/boot/fonts/10x18b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/10x18b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/10x18b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/10x20.fnt ] && rm -f $BASEDIR/boot/fonts/10x20.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/10x20.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/10x20.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/10x20b.fnt ] && rm -f $BASEDIR/boot/fonts/10x20b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/10x20b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/10x20b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/11x22.fnt ] && rm -f $BASEDIR/boot/fonts/11x22.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/11x22.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/11x22.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/11x22b.fnt ] && rm -f $BASEDIR/boot/fonts/11x22b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/11x22b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/11x22b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/12x24.fnt ] && rm -f $BASEDIR/boot/fonts/12x24.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/12x24.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/12x24.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/12x24b.fnt ] && rm -f $BASEDIR/boot/fonts/12x24b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/12x24b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/12x24b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/14x28.fnt ] && rm -f $BASEDIR/boot/fonts/14x28.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/14x28.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/14x28.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/14x28b.fnt ] && rm -f $BASEDIR/boot/fonts/14x28b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/14x28b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/14x28b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/16x32.fnt ] && rm -f $BASEDIR/boot/fonts/16x32.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/16x32.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/16x32.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/16x32b.fnt ] && rm -f $BASEDIR/boot/fonts/16x32b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/16x32b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/16x32b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/6x12.fnt ] && rm -f $BASEDIR/boot/fonts/6x12.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/6x12.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/6x12.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/6x12b.fnt ] && rm -f $BASEDIR/boot/fonts/6x12b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/6x12b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/6x12b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x14.fnt ] && rm -f $BASEDIR/boot/fonts/8x14.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x14.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x14.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x14b.fnt ] && rm -f $BASEDIR/boot/fonts/8x14b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x14b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x14b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x14v.fnt ] && rm -f $BASEDIR/boot/fonts/8x14v.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x14v.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x14v.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x16.fnt ] && rm -f $BASEDIR/boot/fonts/8x16.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x16.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x16.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x16b.fnt ] && rm -f $BASEDIR/boot/fonts/8x16b.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x16b.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x16b.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/8x16v.fnt ] && rm -f $BASEDIR/boot/fonts/8x16v.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/8x16v.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/8x16v.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/Gallant19.fnt ] && rm -f $BASEDIR/boot/fonts/Gallant19.fnt
	else
	    chmod 0444 "$BASEDIR/boot/fonts/Gallant19.fnt"
	    chown root:bin "$BASEDIR/boot/fonts/Gallant19.fnt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/boot/fonts/fonts.dir ] && rm -f $BASEDIR/boot/fonts/fonts.dir
	else
	    chmod 0444 "$BASEDIR/boot/fonts/fonts.dir"
	    chown root:bin "$BASEDIR/boot/fonts/fonts.dir"
	fi
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/usr/share/lib && ln -f -s ../../../boot/fonts $BASEDIR/usr/share/lib/fonts)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

